package scapi.gui;


import javax.swing.*;
import java.awt.*;

/**
 *
 * @author Miguel Corona
 *
 */
public class Splash extends JWindow
{
    /**
	 *
	 */
	private static final long serialVersionUID = 1L;
	public Splash(String filename)
    {
        JLabel l = new JLabel(new ImageIcon(getClass().getResource(filename)));
        getContentPane().add(l, BorderLayout.CENTER);
        pack();
        Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
        Dimension labelSize = l.getPreferredSize();
        setLocation(screenSize.width/2 - (labelSize.width/2),
                    screenSize.height/2 - (labelSize.height/2));

        final int pause = 3000;

        Runnable waitRunner = new Runnable()
            {
                public void run()
                {
                    try
                        {
                            Thread.sleep(pause);
                            Login.iniciar();
                        	setVisible(false);
                            dispose();
                        }
                    catch(Exception e)
                        {
                            e.printStackTrace();
                        }
                }
            };
        setVisible(true);
        Thread splashThread = new Thread(waitRunner, "SplashThread");
        splashThread.start();
    }
}
